<template>
	<view class="container">
		<header-view type="second" leftShow rightShow>{{$t("添加银行卡")}}</header-view>
		<view class="content">
			<view class="item flex">
				<view class="name flex">{{$t("持卡人姓名")}}：</view>
				<u--input :placeholder="$t('请输入持卡人姓名')" border="none" v-model="data.bankname" type="text" color="#fff"
					placeholderStyle="{color:'grey'}"></u--input>
			</view>
			<view class="item flex">
				<view class="name flex">{{$t("银行卡号：")}}</view>
				<u--input :placeholder="$t('请输入银行卡号')" border="none" v-model="data.bankcardno" type="number" color="#fff"
					placeholderStyle="{color:'grey'}"></u--input>
			</view>
			<view class="item flex">
				<view class="name flex">{{$t("银行卡类型：")}}</view>
				<u--input :placeholder="$t('请输入银行卡类型')" border="none" v-model="data.banktype" type="text" color="#fff"
					placeholderStyle="{color:'grey'}"></u--input>
			</view>
			<view class="item flex">
				<view class="name flex">{{$t("分行名称：")}}</view>
				<u--input :placeholder="$t('请输入分行名称')" border="none" v-model="data.bank" type="text" color="#fff"
					placeholderStyle="{color:'grey'}"></u--input>
			</view>
			<view class="item flex">
				<view class="name flex">{{$t("分行代码：")}}</view>
				<u--input :placeholder="$t('请输入分行代码')" border="none" v-model="data.bankcode" type="text" color="#fff"
					placeholderStyle="{color:'grey'}"></u--input>
			</view>
			<u-button class="submit" :text="$t('提交')" @tap="submit"></u-button>
		</view>
	</view>
</template>

<script>
	import headerView from "@/components/headerView/index.vue"
	import {
		walletAddApi
	} from "@/api/api.js"
	export default {
		components: {
			headerView
		},
		data() {
			return {
				data: {
					bankname: "",
					bankcardno: "",
					banktype: "",
					bank: "",
					bankcode: "",
				}
			};
		},
		methods: {
			submit() {
				if (this.data.bankname == "") {
					uni.$u.toast(this.$t("持卡人不能为空"))
					return
				}
				if (this.data.bankcardno == "") {
					uni.$u.toast(this.$t("银行卡号不能为空"))
					return
				}
				if (this.data.banktype == "") {
					uni.$u.toast(this.$t("银行卡类型不能为空"))
					return
				}
				if (this.data.bank == "") {
					uni.$u.toast(this.$t("分行名称不能为空"))
					return
				}
				if (this.data.bankcode == "") {
					uni.$u.toast(this.$t("分行代码不能为空"))
					return
				}
				walletAddApi(this.data).then(res => {
					uni.$u.toast(res.data.msg)
					setTimeout(() => {
						uni.navigateBack()
					}, 500)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {


		.content {
			padding: 0 24rpx;

			.item {
				height: 100rpx;
				background: #1f2039;
				border-radius: 20rpx;
				margin-bottom: 30rpx;
				padding: 0 20rpx;

				.name {
					width: 180rpx;
					height: 100rpx;
					font-size: 32rpx;
					font-weight: 400;
					color: #fefefe;
				}

				.u-input {
					flex: 1;
					height: 100rpx;
					line-height: 100rpx;
				}
			}

			.submit {
				height: 88rpx;
				background: #4c3d89;
				border-radius: 44rpx;
				font-size: 32rpx;
				font-weight: 400;
				color: #fff;
				margin-top: 66rpx;
				border: none;
			}
		}
	}
</style>